 Public Class Form1

    Private Sub btnexchange_Click(sender As Object, e As EventArgs) Handles btnexchange.Click
        Dim ExD2R As Double
        Dim ExD2B As Double
        Dim ExB2R As Double
        Dim Amount As Double
        Dim ExResult As Double
        If txtDollartoR.Text = "" Then
            MsgBox("Please input Exchange Rate")
            txtDollartoR.Focus()
            Exit Sub
        ElseIf txtDollartoB.Text = "" Then
            MsgBox("Please input Exchange Rate")
            txtDollartoB.Focus()
            Exit Sub
        ElseIf txtamoal.Text = "" Then
            MsgBox("Please input Exchange Amoal")
            txtamoal.Focus()
            Exit Sub
        End If
        ExD2R = Val(txtDollartoR.Text)
        ExD2B = Val(txtDollartoB.Text)
        ExB2R = ExD2R / ExD2B
        Amount = Val(txtamoal.Text)

        If ComboBoxType.Text = "Dollar-to-Riel" Then
            ExResult = Amount * ExD2R
        ElseIf ComboBoxType.Text = "Dollar-to-Bath" Then
            ExResult = Amount * ExD2B
        ElseIf ComboBoxType.Text = "Riel-to-Dollar" Then
            ExResult = Amount / ExD2R
        ElseIf ComboBoxType.Text = "Bath-to-Dollar" Then
            ExResult = Amount / ExD2B
        ElseIf ComboBoxType.Text = "Riel-to-Bath" Then
            ExResult = Int(Amount / ExB2R)
        Else
            ExResult = Int(Amount * ExB2R)
        End If
        txtexchange.Text = ExResult
    End Sub


    Private Sub ComboBoxType_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxType.SelectedIndexChanged
        Select Case ComboBoxType.Text
            Case "Dolla-to-Riel"
                lblAmoal.Text = "Dollar"
                lblExchange.Text = "Riel"
            Case "Riel-to-Dollar"
                lblAmoal.Text = "Riel"
                lblExchange.Text = "Dollar"
            Case "Dollar-to-Bath"
                lblAmoal.Text = "Dollar"
                lblExchange.Text = "Bath"
            Case "Bath-to-Dollar"
                lblAmoal.Text = "Bath"
                lblExchange.Text = "Dollar"
            Case "Bath-to-Riel"
                lblAmoal.Text = "Bath"
                lblExchange.Text = "Riel"
            Case "Riel-to-Bath"
                lblAmoal.Text = "Riel"
                lblExchange.Text = "Bath"

        End Select
    End Sub
End Class
